package tool;

import java.io.File;
import java.io.IOException;

	/**
	 * @author jwb09119
	 * @date 2013/11/13
	 * 
	 * This is a more minimal launch class for this application - is should handle only:
	 * - Getting input from the command line
	 * - Validating input from the command line
	 * - Printing usage information
	 * - Passing valid parameters on to the rest of the application
	 */

public class RunThis {

    public static final String VERSION = "0.2.131217";
    private static String useInfo  = "Java Interface Metrics Tool v"+VERSION+"\n"+
                              "\n"+
                              "Expected use:\n"+
                              "\t jimt PATH_TO_PARAMETER_FILE\n"+
                              "\n"+
                              "Parameters file lines shoud contain full paths to source code to be analysed\n"+
                              "and full paths to any dependencies e.g:\n"+
                              "\n"+
                              "\t# Comment line\n"+
                              "\t@[path to source code]\n"+
                              "\t-[path to dependency]\n"+
                              "\n"+
                              "Output files will appear in the same folder as the root folder of the source\n"+
                              "code specified with a file-prefix relating to the name of the source code root\n"+
                              "directory.";
    
	@SuppressWarnings("unused")
    private static Workbench bench;
	
	public static void main (String[] args) {
	    
		//If input is a use query, print the relevant information
	    if (args.length != 1) {
	        System.out.println(useInfo);
	        System.exit(0);
	    }
		
		//If input is a location, check validity and pass to rest of application or fail.
	    File parameterFile = new File (args[0]);
		
	    if (parameterFile.exists()) {
	        
	        try {
	            System.out.println("Java Interface Metrics Tool v"+VERSION);
	            System.out.println("---------------------------------------");
	            System.out.println("Found: "+parameterFile.getAbsolutePath());
	            System.out.println("Setting up workbench");
                bench = new Workbench(parameterFile);
                
            } catch (IOException e) {
                
                System.err.println("Workbench unable to process specification file:\n"+e.getMessage());
                e.printStackTrace();
                
            }
	        
	    }
		
	}
	
}
